$(function () {
    $('#all_type').click(function () {
        $(this).find('span').toggleClass('glyphicon glyphicon-chevron-up glyphicon glyphicon-chevron-down')
        $('#second_menu01').toggle()


    })
    $('#all_sort').click(function () {
        $(this).find('span').toggleClass('glyphicon glyphicon-chevron-up glyphicon glyphicon-chevron-down')
        $('#second_menu02').toggle()

    })

    $('.addGoods').click(function () {
        $add = $(this)
        var goodsid = $add.attr('goodsid');
        // alert(1)
        // alert(goodsid)
        $.getJSON('/app/addcart/', {'goodsid': goodsid, 'means': 'add'}, function (data) {
            // $("#total_price").html(data['total_price']);
            if (data['status'] == 204) {
                window.location.href = '/app/login/'
            }
            if (data['status'] == 201) {
                // alert(2)
                $add.prev().html('0')
            }
            else {
                $add.prev().html(data['c_goods_num'])
            }
        })
    })

    $('.decGoods').click(function () {
        $dec = $(this)
        var goodsid = $dec.attr('id');
        // alert(goodsid)
        $.getJSON('/app/addcart/', {'goodsid': goodsid, 'means': 'dec'}, function (data) {
            // $("#total_price").html(data['total_price']);
            if (data['status'] == 204) {
                window.location.href = '/app/login/'
            }
            if (data['status'] == 201) {
                // alert(2)
                $dec.next().html('0')
            }
            else {
                $dec.next().html(data['c_goods_num'])
            }
        })
    })


})